<?php
 header("Content-type: text/html; charset=utf-8"); include DAEM_CONFIG_ROOT."chineseDictionary.php"; function str_split_unicode($str,$l=0) { if($l>0) { $ret = array(); $len = mb_strlen($str,"UTF-8"); for($i=0;$i<$len;$i+=$l) { $ret[] = mb_substr($str,$i,$l,"UTF-8"); } return $ret; } return preg_split("//u",$str,-1,PREG_SPLIT_NO_EMPTY); } function nationalStandardCode($chinese) { global $chineseDictAry; $pos = isset($chineseDictAry[$chinese]) ? $chineseDictAry[$chinese] : 0; return $pos; } function parseStringStandardCode($string) { $code = 0; $strAry = str_split_unicode($string); foreach($strAry as $key=>$val) { $code += nationalStandardCode($val); } return $code; } 